from utils import utils
from model import excel_builder
import argparse
import json
def init_params():
    paser = argparse.ArgumentParser(description="excel builder")
    paser.add_argument("-type",type=str,help="ts|lua|c#",required=True,default="ts")
    paser.add_argument("-in",type=str,help="source dir",required=True)
    paser.add_argument("-out_bin",type=str,help="out dir",required=True)
    paser.add_argument("-out_model",type=str,help="out dir",required=True)
    return paser
if __name__ == "__main__":
    paser = init_params()
    args = vars(paser.parse_args())

    source_dir = args["in"]

    excel_files = []

    utils.get_filelist(source_dir,excel_files,True,[".xlsx"])

    sheet_names = []
    for filepath in excel_files:
        if filepath.find("~") >= 0:
            continue
        builder = excel_builder.excel_builder(filepath,args)
        builder.load()

        for sheet_name in builder.sheet_objs:
            sheet_names.append(sheet_name)

    bin_configs = args["out_bin"] + "/config.json"
    utils.writeFile(bin_configs,json.dumps(sheet_names))




